import click
import sys
import array
import serial

if __name__ == '__main__':
    ser = serial.Serial(sys.argv[1], 115200, timeout=0.5)
    if ser.isOpen():
        print("open success")
    else:
        print("open failed")

    while 1:
        print('Please input your context:')
        buf = input().encode('utf-8')

        if buf != '':
            b=array.array('B', buf)
            # sock.sendto(b, addr)
            ser.write(b)

        if (buf == 'exit'):
            sys.exit()